package com.dq.eduservice.controller;

import com.dq.commonutils.vo.Result;
import com.dq.eduservice.entity.subject.Subject;
import com.dq.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.List;

/**
 * eduSubject-API
 *
 * @author Dq
 * @since 2022-07-21 15:39:22
 */
@RestController
@RequestMapping("eduservice/subject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService subjectService;

    /**
     * 添加课程分类
     * 1。 获取上传的文件流，把文件内容读取出来
     * @param file
     */
    @PostMapping("addSubject")
    public Result addSubject(MultipartFile file){
        subjectService.addSubject(file,subjectService);
        return Result.success(null);
    }

    /**
     * 获取所有的分类  2级目录
     * @return
     */
    @GetMapping("getSubjectList")
    public Result getSubjectList(){
        List<Subject> subjectList=subjectService.getSubjectList();
        return Result.success(subjectList);
    }


}